<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
	<style type="text/css">
		body, html {width: 100%;height: 100%;margin:0;font-family:"微软雅黑";}
		#allmap{width:100%;height:98%;}
		p{margin-left:5px; font-size:14px;}
	</style>
	<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=OPNTa5C9WCXt0X2HduhY0XOQriFD3N4z"></script>
	<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
	<title>仓库地图</title>
</head>
<body>
	<div id="allmap"></div>
	<!-- <p>点击标注点，可查看由纯文本构成的简单型信息窗口</p> -->
</body>
</html>
<script type="text/javascript">
	// 百度地图API功能
	var map = new BMap.Map("allmap");
	map.centerAndZoom(new BMap.Point(103.815918,36.011809), 6);	//初始地图中心 武汉 ,地图放大级别 5级

	//添加地图控件
	var top_right_navigation = new BMap.NavigationControl({anchor: BMAP_ANCHOR_TOP_RIGHT, type: BMAP_NAVIGATION_CONTROL_SMALL}); //右上角，仅包含平移和缩放按钮
	map.addControl(top_right_navigation); 


	$(function(){

		//通过接口获取所有点位信息
		$.post("http://180.168.160.38:18080/vmc/api/warehouse/all.do",function(result){

			var whArray = result.data;

			for(var i=0;i<whArray.length;i++){
						
				wh = whArray[i];
				
				showWH(wh);
			}

		},"json");


		//在地图上显示仓库
		function showWH(wh){

			//添加点位
			var point = new BMap.Point(wh.lat,wh.lng);
			var marker = new BMap.Marker(point);  // 创建标注
			
			var infoWindow = new BMap.InfoWindow("地址："+wh.address, { width : 200, height: 100,   title : wh.name });  // 创建信息窗口对象 
			marker.addEventListener("click", function(){          
				map.openInfoWindow(infoWindow,point); //开启信息窗口
			});

			map.addOverlay(marker); 
		
		}


	});


</script>
